package org.bestever.slickgame;
 
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
 
public class Game extends BasicGame{
 
    float x = 180;
    float y = 700;
    
    float height = 50;
    float width = 20;
    
    static int windowx = 400;
    static int windowy = 800;
    
    float scale = .33f;
 
    public Game()
    {
        super("BEST");
    }
 
    @Override
    public void init(GameContainer gc)
			throws SlickException {
    }
 
    @Override
    public void update(GameContainer gc, int delta)
			throws SlickException
    {
        Input input = gc.getInput();
 
        if(input.isKeyDown(Input.KEY_W))
        {
        	if (!((y + (.2 * delta)) < 0))
        		y -= .2 * delta;
        }
        
        if(input.isKeyDown(Input.KEY_A))
        {
        	if (!((x + (.2 * delta)) < 0))
        		x -= .2 * delta;
        }
        
        if(input.isKeyDown(Input.KEY_S))
        {
        	if (!((y + (.2 * delta) + height) > windowy))
        		y += .2 * delta;
        }
 
        if(input.isKeyDown(Input.KEY_D))
        {
        	if (!((x + (.2 * delta) + width) > windowx))
        		x += .2 * delta;
        }
    }
 
    public void render(GameContainer gc, Graphics g)
			throws SlickException
    {
        g.fillRect(x,y,width,height);
    }
 
    public static void main(String[] args)
			throws SlickException
    {
         AppGameContainer app =
			new AppGameContainer( new Game() );
 
         app.setDisplayMode(windowx, windowy, false);
         app.start();
    }
}